// 创建日期对象
// console.log(new Date());
// console.log(new Date('2022-10-01T08:09:10'));
// console.log(new Date(2022, 10, 11, 10, 31, 21));

// let time = new Date().getTime();
// console.log(new Date(time));
// Date.now()

// let now = new Date();

// console.log(now.getFullYear());
// console.log(now.getMonth() + 1);
// console.log(now.getDate());
// console.log(now.getHours());
// console.log(now.getMinutes());
// console.log(now.getSeconds());
// console.log("星期" + now.getDay());

// console.log(now.toJSON());
// console.log(now.toDateString());
// console.log(now.toLocaleString());
// console.log(now.toLocaleDateString());
// console.log(now.toLocaleTimeString());
// console.log(now.toUTCString());

// xxxx年xx月xx日 xx点xx分xx秒 星期x

function parseDate(date) {

    if (typeof (date) != 'object') {
        date = Date.now();
    }
    let year = date.getFullYear();
    let month = date.getMonth() + 1;
    let day = date.getDate();
    let hours = date.getHours();
    let minute = date.getMinutes();
    let seconds = date.getSeconds();
    let week = date.getDay();
    return `${year}年${month}月${day}日 ${hours}点${minute}分${seconds}秒 星期${week}`
}

// 原型
Date.prototype.chineseDate = function () {
    let year = this.getFullYear();
    let month = this.getMonth() + 1;
    let day = this.getDate();
    let hours = this.getHours();
    let minute = this.getMinutes();
    let seconds = this.getSeconds();
    let week = this.getDay();
    return `${year}年${month}月${day}日 ${hours}点${minute}分${seconds}秒 星期${week}`
}

console.log(Date.prototype);
let now = new Date();
console.log(now.chineseDate());

// let str = parseDate(now);

// console.log(str);
